package xin.yangshuai.jvm01;

import java.lang.reflect.InvocationTargetException;

/**
 * A
 *
 * @author shuai
 * @date 2022/1/4
 */
public class A {


    static A a = new A();
    static B b = new B();
    static final int i = B.i;
    static int c = 10;

    static {
        System.out.println("static A");

    }

    {
        System.out.println("A");
        System.out.println(i);
        System.out.println(c);
    }

    public static void main(String[] args) {


    }
}

class B {

    static  int i = 20;

    static {
        System.out.println("static B");
    }

    {
        System.out.println("B");
    }
}

class C {
    private int i = 10;
    int j = 30;

    public void cc() {
        System.out.println("c.i=" + i);
        System.out.println("c.j=" + j);
    }
}

class D extends C {
    private int i = 20;
    int j = 40;

    public void info() {
        System.out.println("super.j=" + super.j);
        System.out.println("d.i=" + i);
        System.out.println("d.j=" + j);
    }
}

class Hello {
    public static void main(String[] args) throws IllegalAccessException, InstantiationException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException {

//        D d = new D();
//        d.cc();
//        d.info();

//        new A();

//        Class<?> aClass = Class.forName("xin.yangshuai.jvm.A");
//        Class<?> bClass = Class.forName("xin.yangshuai.jvm.B");
//        bClass.getClassLoader().loadClass("xin.yangshuai.jvm.A");

//        Object o = aClass.newInstance();
//        Class<A> aClass = A.class;
//        aClass.getClassLoader().loadClass("xin.yangshuai.jvm.A");

//        Constructor<?> constructor = A.class.getConstructor();
//
//        Object o = constructor.newInstance();

        String aa = "123"+"456";
        String bb = new String("789")+new String("012");

        bb.intern();

        String cc = "123456";

        String dd = "789012";

        System.out.println(aa == cc);
        System.out.println(bb == dd);
    }
}
